package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.Extractor;
import java.io.IOException;

public final class agz implements Extractor {
    public static final adw ॱ = agw.ˋ;
    private int ʻ;
    private ady ˊ;
    private aef ˋ;
    private int ˎ;
    private agx ˏ;

    public boolean ˎ(adv o_adv) throws IOException, InterruptedException {
        return ahf.ˊ(o_adv) != null;
    }

    public void ˏ(ady o_ady) {
        this.ˊ = o_ady;
        this.ˋ = o_ady.ˊ(0, 1);
        this.ˏ = null;
        o_ady.ˊ();
    }

    public void ˊ(long j, long j2) {
        this.ʻ = 0;
    }

    public void ॱ() {
    }

    public int ˎ(adv o_adv, adz o_adz) throws IOException, InterruptedException {
        if (this.ˏ == null) {
            this.ˏ = ahf.ˊ(o_adv);
            if (this.ˏ == null) {
                throw new ParserException("Unsupported or unrecognized wav header.");
            }
            this.ˋ.ˎ(Format.ˋ(null, "audio/raw", null, this.ˏ.ʽ(), 32768, this.ˏ.ॱॱ(), this.ˏ.ʼ(), this.ˏ.ᐝ(), null, null, 0, null));
            this.ˎ = this.ˏ.ॱ();
        }
        if (!this.ˏ.ˎ()) {
            ahf.ˎ(o_adv, this.ˏ);
            this.ˊ.ˎ(this.ˏ);
        }
        long ˋ = this.ˏ.ˋ();
        amm.ˏ(ˋ != -1);
        long ˊ = ˋ - o_adv.ˊ();
        if (ˊ <= 0) {
            return -1;
        }
        int ˏ = this.ˋ.ˏ(o_adv, (int) Math.min((long) (32768 - this.ʻ), ˊ), true);
        if (ˏ != -1) {
            this.ʻ += ˏ;
        }
        int i = this.ʻ / this.ˎ;
        if (i > 0) {
            ˋ = this.ˏ.ˋ(o_adv.ˊ() - ((long) this.ʻ));
            int i2 = i * this.ˎ;
            this.ʻ -= i2;
            this.ˋ.ˋ(ˋ, 1, i2, this.ʻ, null);
        }
        return ˏ == -1 ? -1 : 0;
    }
}
